import axios from "axios";
import { ElLoading } from "element-plus";
import { ElMessage } from "element-plus";

let server = axios.create({
  timeout: 5 * 1000
});
let load: any;
server.interceptors.request.use(config => {
  // load= ElLoading.service({
  //     lock: true,
  //     text: '客官稍等片刻',
  //     spinner: 'el-icon-loading',
  //     background: 'rgba(0, 0, 0, 0.7)'
  //   });

  return config;
});

server.interceptors.response.use(res => {
  // load.close()
  if (res.status !== 200) {
    ElMessage.error("数据请求出错");
  }

  return res;
});

export default server;

/* 
     提交检查
      
      "prettier --write .", "eslint  --fix",
      "vue-cli-service lint",
      "git add"

*/
